
using System;
using System.Drawing;

using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Collections.Generic;
using System.Linq;

namespace Socialite
{
	public partial class UserGroupCell : UITableViewCell
	{
		public UserGroupCell() : base()
		{
		}
		
		public UserGroupCell(IntPtr handle) : base(handle)
		{
		}
		
		/// <summary>
		/// Binds the data to cell.
		/// </summary>
		/// <param name='place'>
		/// Place.
		/// </param>
		public void BindDataToCell (IEnumerable<User> users, Action<User> fnUserAction)
		{
			if (users.Count() > 0) {
				UserAButton.SetBackgroundImage (UIImage.FromFile (users.ElementAt (0).ProfilePhotoPath), UIControlState.Normal);
				UserAButton.TouchUpInside += (obj, sender) => {
					fnUserAction (users.ElementAt (0));};
			}
			else
				UserAButton.Hidden = true;

			if (users.Count() > 1) {
				UserBButton.SetBackgroundImage (UIImage.FromFile (users.ElementAt (1).ProfilePhotoPath), UIControlState.Normal);
				UserBButton.TouchUpInside += (obj, sender) => {
					fnUserAction (users.ElementAt (1));};
			
			}
			else
				UserBButton.Hidden = true;

			if (users.Count() > 2) {
				UserCButton.SetBackgroundImage (UIImage.FromFile (users.ElementAt (2).ProfilePhotoPath), UIControlState.Normal);

				UserCButton.TouchUpInside += (obj, sender) => {
					fnUserAction (users.ElementAt (2));};
			}
			else
				UserCButton.Hidden = true;
		}
	}
}